#include "iuFramework.h"


using namespace Pure;


iuFramework::iuFramework( HINSTANCE hinst, WNDPROC winproc )
{
    mRunning = false;
    mWindows = 0;

    mWindows = new iuWindows;

    Initialize();

    if( mWindows )
    {
		mWindows->SetHinstance( hinst );
        mWindows->SetWndProc( winproc ? winproc : DefaultWinProcCallback );

		SetRunning( mWindows->Initialize() );
    }
}


iuFramework::~iuFramework( void )
{
    Clear();
}


bool iuFramework::Initialize( void )
{       
    //if( !load_app() )
    {
        mWindows->SetTitle( "dummy" );
        mWindows->SetPos( 0x80000000, 0x80000000 );
        mWindows->SetSize( 0x80000000, 0x80000000 );
    }


    return true;
}


void iuFramework::Clear( void )
{
    if( mWindows )
    {
        delete mWindows;
        mWindows = 0;
    }
}


/*
bool SFFramework::load_app( void )
{
	return true;
}
*/


LRESULT CALLBACK iuFramework::DefaultWinProcCallback( HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
    case WM_DESTROY :
        {
            PostQuitMessage( 0 );
        }
        return 0;
    }

    return ( DefWindowProc( hwnd, msg, wParam, lParam ) );
}